/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package race.model;

import java.io.IOException;
import java.util.Random;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import race.util.BackgroundUtil;

/**
 *
 * @author BBXP
 */
public class SpeedBooster {
    private Sprite sprite;
    private int posX;
    private int posY;
    private Random r = new Random();
    public SpeedBooster(){
        try {
            sprite = new Sprite(Image.createImage("/images/booster.png"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public Point randomPosition(){
        int xLimit = BackgroundUtil.COLS - 3;// 11 -3 = 8
        int yLimit = BackgroundUtil.ROWS - 20; //200 - 20 = 180

        posX = (r.nextInt(xLimit)+2) * 24; // 0-7  +2 2-9
        posY = (r.nextInt(yLimit) + 10) * 24; // 0-179 +10 10 - 189
        sprite.setPosition(posX, posY);
        return new Point(posX, posY);
    }

    public Sprite getSprite(){
        return sprite;
    }
}
